<?php
use common\models\BusHealthCustom;
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;

?>

<style>
	input[type="checkbox"] + label i {
		display: inline-block;
		width: 17px;
		height: 17px;
		background: url("<?= Yii::getAlias('@web/backend/img/member/selectednone.png') ?>") no-repeat 0 0;
	}
	input[type="checkbox"]:checked + label i {
		background: url("<?= Yii::getAlias('@web/backend/img/member/selected.png') ?>") no-repeat;
	}
	.consit-con{position: relative;}
	.consit-con .msg-box{position: absolute;right: -90px;}
	.consit-con .msg-box .n-icon{margin-right: 0!important;}

	.newInput input{margin-top: 30px;width: 100%;height: 44px;}

	@media (min-width: 992px) and (max-width: 1439px){
		#consit{
			display: -webkit-box;
			display: -moz-box;
			display: -ms-flexbox;
			display: -webkit-flex;
			display: flex;
			-webkit-justify-content: space-between;
			justify-content: space-between;
		}
		#consit span{margin-right: 0;}
	}

</style>

<?= $this->render('header'); ?>

<?php ActiveForm::begin();?>
<div class="row borB">
	<div class="container">
		<div id="consit" class="mg20-y">
			<span class="consit-con">身高（cm）<em><?= Html::activeTextInput($BusMember, 'member_height',['data-rule' => 'int3','data-rule-int3'=>"[/^\d{1,3}$/, '最长3位数字']"]) ?></em></span>
			<span class="consit-con">体重（kg）<em><?= Html::activeTextInput($BusMember, 'member_weight',['data-rule' => 'int3','data-rule-int3'=>"[/^\d{1,3}$/, '最长3位数字']"]) ?></em></span>
			<span class="consit-con">胸围（cm）<em><?= Html::activeTextInput($BusMember, 'member_breast',['data-rule' => 'int3','data-rule-int3'=>"[/^\d{1,3}$/, '最长3位数字']"]) ?></em></span>
			<span class="consit-con">腰围（cm）<em><?= Html::activeTextInput($BusMember, 'member_waist',['data-rule' => 'int3','data-rule-int3'=>"[/^\d{1,3}$/, '最长3位数字']"]) ?></em></span>
			<span class="consit-con">臀围（cm）<em><?= Html::activeTextInput($BusMember, 'member_hip',['data-rule' => 'int3','data-rule-int3'=>"[/^\d{1,3}$/, '最长3位数字']"]) ?></em></span>
		</div>
	</div>

</div>
<div id="consitList" class="container">

        <?php $i = 1; foreach($healthList as $health): ?>
		<dl>
			<dt>
                <img src="<?= Yii::getAlias('@web/backend/img/member/' . $health['icon']) ?>" alt="<?= $health['health_name'] ?>"/><?= $health['health_name'] ?>
            </dt>
			<dd>

                <?php $j=1; foreach($health['_item'] as $item): ?>
               <span>
                   <input id="checkbox-<?= $i ?>-<?= $j ?>" type="checkbox" name="attr_id[]" <?= in_array($item['health_id'], $arrayHealthId) ? 'onchange="textInput(this)"' : '' ?> value="<?= $item['health_id'] ?>" <?= in_array($item['health_id'], $memberHealthListId) ? 'checked' : '' ?>/>
                   <label for="checkbox-<?= $i ?>-<?= $j ?>"><i></i><em><?= $item['health_name'] ?></em></label>
               </span>

					<?php
					   if (in_array($item['health_id'], $arrayHealthId)) {
							echo '<div class="newInput"><input type="text" name="custom_name_'. $item['health_id'] .'" style="display: '. (in_array($item['health_id'], $memberHealthListId) ? 'inline' : 'none') .'" class="n-valid custom_name_'. $item['health_id'] .'" value="'. (in_array($item['health_id'], $memberHealthListId) ? BusHealthCustom::getHealthName($_GET['id'], $item['health_id']) : '') .'" ></div>';
					}
					?>

                <?php $j++; endforeach; ?>

			</dd>
		</dl>
        <?php $i++; endforeach; ?>

	<div class="mt20">
		<?= Html::activeTextarea($BusMember, 'constitution_remark', ['class' => '', 'placeholder' => '请输入您对该会员的备注信息','data-rule' => 'length[~200]']) ?>

	</div>

		<div class="text-center mt20" style="margin-bottom: 37px;">
			<a  class="btnBg dis text-center  " style=" height: 40px;overflow: hidden;">
				<input  type="submit" value="保存"  style="display: block; width: 100%; background: 0; border:0;line-height: 40px;">
			</a>
		</div>
</div>
<?php ActiveForm::end() ?>

<?php $this->beginBlock('js_index') ?>

<?php
if (Yii::$app->getSession()->hasFlash('success')) {
	echo "layer.alert('修改成功', {icon:1})";
}
?>

function textInput(obj)
{
	var id = $(obj).val();
	if (obj.checked) {
		$('.custom_name_' + id).css({'display': 'inline'});
	} else {
		var custom_name_id = $('.custom_name_' + id);
		custom_name_id.css({'display': 'none'});
		custom_name_id.val('');
	}
}

<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['js_index'], $this::POS_END); ?>


